#ifndef INTERPRETER_PATTERN_H
#define INTERPRETER_PATTERN_H

#include <string>

using namespace std;

class Expression
{
public:
    virtual ~Expression() {}

    virtual bool interpret(string context) = 0;
};

class TerminalExpression : public Expression
{
public:
    TerminalExpression(string data);
    ~TerminalExpression() {}

    bool interpret(string context) override;

private:
    string data;
};

class OrExpression : public Expression
{
public:
    OrExpression(Expression* expr1, Expression* expr2);
    ~OrExpression();

    bool interpret(string context) override;

private:
    Expression* expr1;
    Expression* expr2;
};

class AndExpression : public Expression
{
public:
    AndExpression(Expression* expr1, Expression* expr2);
    ~AndExpression();

    bool interpret(string context) override;

private:
    Expression* expr1;
    Expression* expr2;
};

#endif // INTERPRETER_PATTERN_H

/*
Expression* getMaleExpression();
Expression* getMarriedWomanExpression();

    Expression* isMale = getMaleExpression();
    Expression* isMarriedWoman = getMarriedWomanExpression();

    cout << "John is male? " << isMale->interpret("John") << endl;
    cout << "Julie is a married women? " << isMarriedWoman->interpret("Married Julie") << endl;

Expression* getMaleExpression()
{
    Expression* robert = new TerminalExpression("Robert");
    Expression* john = new TerminalExpression("John");
    return new OrExpression(robert, john);
}

Expression* getMarriedWomanExpression()
{
    Expression* julie = new TerminalExpression("Julie");
    Expression* married = new TerminalExpression("Married");
    return new AndExpression(julie, married);
}

*/
